package com.lujieni.springboothutool.utils;

import cn.hutool.core.util.ReflectUtil;
import org.springframework.util.StringUtils;

import java.lang.reflect.Field;

public class DanqingUtil {

    public static void setFieldValue(Object object, String fieldName, String fieldValue){
        if(object == null || !StringUtils.hasText(fieldName)){
            return;
        }
        // 会递归查找父类
        Field field = ReflectUtil.getField(object.getClass(), fieldName);
        if(field != null){
            // 如果目标字段是List,fieldValue是String类型也可以赋值 牛逼
            ReflectUtil.setFieldValue(object, field, fieldValue);
        }
    }


    public static void main(String[] args) {




    }




}
